/**
 * Created by Administrator on 2017/5/14 0014.
 */
var net = require('net');

var HOST = '127.0.0.1';
var PORT = 9999;

var client = new net.Socket();
client.connect(PORT, HOST, function() {

    console.log('CONNECTED TO: ' + HOST + ':' + PORT);
   var data={
       "cashierId":"2c9cd9f35b80566b015b805882560002",
       "token" : "weqwewqe",
       "operation" : "getGoodsByOrderId",
       "order_id":"2c9cd9f75b5700dc015b5702d7cb0002",
       "stamp" :  "1494136242"
   };

    client.write(JSON.stringify(data));

});

// 为客户端添加“data”事件处理函数
// data是服务器发回的数据
client.on('data', function(data) {

    console.log('DATA: ' + data);
    // 完全关闭连接
    client.destroy();

});

// 为客户端添加“close”事件处理函数
client.on('close', function() {
    console.log('Connection closed');
});